<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%;margin-top:0px"
      >
        <el-table-column align="center" prop="coupon.title" label="优惠券名" width="150" />
        <el-table-column align="center" prop="use_time" label="使用时间" width="180" />
        <el-table-column align="center" prop="user.nickname" label="使用用户" width="120" />
        <el-table-column align="center" prop="user.realname" label="真实姓名" width="120" />
        <el-table-column align="center" prop="is_use" label="是否使用" width="120">
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_use=== 1 ? 'success' : 'primary' ">
              {{ scope.row.is_use ===1 ? '已使用' : '未使用' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="order_info.sn" label="订单号" width="220" />
        <el-table-column align="center" prop="coupon.period" label="有效期/天" width="120" />
        <el-table-column align="center" prop="coupon.desc" label="描述" />
        <!-- <el-table-column
          prop="telephone"
          fixed="right"
          width="240"
          label="操作"
        >
          <template slot-scope="scope">
            <router-link :to="'/ad_abt/ad_sort/form?id=' + scope.row.id">
            <el-button
              type="primary"
              icon="el-icon-edit"
              @click="onEdit(scope.row.id)"
            />
            </router-link>
            <el-button
              type="danger"
              icon="el-icon-delete"
              @click="onDel(scope.row.id)"
            />
          </template>
        </el-table-column> -->
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from '../../components/control/control'
export default {
  name:'coupon_usage',
  components: { control },
  data() {
    return {
      config: [
        { type: 'text', placeholder: '请输入优惠券名', field: 'coupon_title', val: '' }
      ],
      value: '',
      searchWhere: {
        coupon_title: ''
      },
      tableData: [],
      total: 0,
      current_page: 1,
      per_page: 14,
      id: 0
    }
  },
  activated(){
    // if(this.$getUpdate()){
      this.onSearch()
    // }
  },
  created() {
    this.onSearch()
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
    onSearch() {
      const form = {}
      form.page = this.current_page
      form.map = this.searchWhere
      this.get('/shop/Coupon/user', form, 'POST').then(e => {
        this.tableData = e.list.data
        this.per_page = e.list.per_page
        this.total = e.list.total
        this.current_page = e.list.current_page
      })
    }
    // 删除
    // onDel(id) {
    //   this.$msg_confirm().then(e => {
    //     if (e) {
    //       this.get('/shop/AdCate/del?id=' + id, this.form, 'POST').then(e => {
    //         this.onSearch()
    //       })
    //     }
    //   })
    // },
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 10px;
}
</style>>
